package com.wgb.movie.model.vo;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.wgb.movie.model.entity.MovieEvaluation;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 评价视图
 *
 * @author <a href="https://github.com/liyupi">程序员鱼皮</a>
 * @from <a href="https://www.code-nav.cn">编程导航学习圈</a>
 */
@Data
public class MovieEvaluationVO implements Serializable {

    /**
     * 评价ID
     */
    private Long id;

    /**
     * 评价内容
     */
    private String evaluationContent;

    /**
     * 电影院ID
     */
    private Long movieId;

    /**
     * 评价者ID
     */
    private Long userId;

    /**
     * 评分（可选，例如1到10）
     */
    private Integer rating;

    /**
     * 评价时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 创建用户信息
     */
    private UserVO user;

    /**
     * 封装类转对象
     *
     * @param movieEvaluationVO
     * @return
     */
    public static MovieEvaluation voToObj(MovieEvaluationVO movieEvaluationVO) {
        if (movieEvaluationVO == null) {
            return null;
        }
        MovieEvaluation movieEvaluation = new MovieEvaluation();
        BeanUtils.copyProperties(movieEvaluationVO, movieEvaluation);
        return movieEvaluation;
    }

    /**
     * 对象转封装类
     *
     * @param movieEvaluation
     * @return
     */
    public static MovieEvaluationVO objToVo(MovieEvaluation movieEvaluation) {
        if (movieEvaluation == null) {
            return null;
        }
        MovieEvaluationVO movieEvaluationVO = new MovieEvaluationVO();
        BeanUtils.copyProperties(movieEvaluation, movieEvaluationVO);
        return movieEvaluationVO;
    }
}
